<?php
/**
 * 商店模型
 * 
 * @version $Id: Shop.php 292 2012-05-04 03:11:22Z linsir123 $
 */
class modelShop
{
	/**
	 * 根据商店Nick取得列表
	 * // 最多40个
	 */
	public function getList($nicks)
	{
		$data = array();
		if ( ! empty($nicks) && is_array($nicks)) {
			$top = M::topRequest();
			
			///
			foreach ($nicks as $i => $v) {
				$v = trim($v);
				if (empty($v)) {
					unset($nicks[$i]);
					continue;
				}
				
				$shop = $top->shopGet($v);
				if (isset($shop['sid'])) 
					$data[] = $shop;
				else 
					unset($nicks[$i]);
			}
			
			///
			if ( ! empty($data)) {
				$count = count($data);
				$users = $top->usersGet(implode(',', $nicks));
				for ($i=0; $i<$count; $i++) 
					$data[$i]['user'] = $users[$i];
			}
		}
		
		return $data;
	}
	
	/**
	 * 根据商店Nick取得某个商店
	 */
	public function getOne($nick)
	{
		$data = $this->getList(array($nick));
		return isset($data[0]) ? $data[0] : array();
	}
}
